﻿//创建时间: 2011-1-28
//创建作者: 李 城
//功能说明: 通用的匹配方法   
//最后修改: 2011-1-28
using System;
using System.Collections.Generic;

using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using Yorkg.CMS.Plugin;

namespace Yorkg.CMS.Template
{
    /// <summary>
    /// 通用的匹配方法
    /// </summary>
    internal  class MatchUtil
    {
        /// <summary>
        /// 正则表达的选项
        /// </summary>
        private const RegexOptions m_RegexOptions = RegexOptions.Multiline | RegexOptions.IgnoreCase;

        /// <summary>
        /// 找到匹配的MatchCollection
        /// </summary>
        /// <param name="strHtmlContent"></param>
        /// <param name="strRegex"></param>
        /// <returns></returns>
        private static MatchCollection GetMatchCollectionCommon(string strHtmlContent, string strRegex)
        {
            return new Regex(strRegex, m_RegexOptions).Matches(strHtmlContent);
        }

        /// <summary>
        /// 找到第一个匹配的Match
        /// </summary>
        /// <param name="strHtmlContent"></param>
        /// <param name="strRegex"></param>
        /// <returns></returns>
        private static Match GetMatchCommon(string strHtmlContent, string strRegex)
        {
            return new Regex(strRegex, m_RegexOptions).Match(strHtmlContent);
        }

        /// <summary>
        /// 找到第一个匹配的Match
        /// </summary>
        /// <param name="strHtmlContent"></param>
        /// <param name="strRegex"></param>
        /// <param name="oMatch"></param>
        /// <returns></returns>
        private static Match GetMatchCommon(string strHtmlContent, string strRegex, Match oMatch)
        {
            return new Regex(strRegex, m_RegexOptions).Match(strHtmlContent, oMatch.Index);
        }

    }
}
